#include <stdio.h>
#include <stdlib.h>
#include <sqlite3.h>



int name_passwd_did_in_user(char *buff_name, char *buff_passwd)
{
    sqlite3 *db;
    int rc;
    char *sql, **dbResult, *errMsg, *buff_p, *buff_p_1;
    char buff[100] = {0};
    int nRow = 0, nColumn = 0;
    /* Open database */
    rc = sqlite3_open("test.db", &db);
    if (rc)
    {
        fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
        exit(0);
    }
    // char buff_name[10] = "aaa1";
    // char buff_passwd[10] = "111";
    sprintf(buff, "select *  from  user where name='%s' and passwd= '%s' ", buff_name, buff_passwd);
    // sprintf(buff, "select  passwd from  user_reg where  name_text='%s' ", name_text_log);
    sql = buff;
    sqlite3_get_table(db, sql, &dbResult, &nRow, &nColumn, &errMsg);
    if (nRow == 0)
    {
        printf("用户名和密码不对 \n");
        sqlite3_close(db);
        return -1;
    }
    else
    {
        printf("登录正确\n");
        sqlite3_close(db);
        return 0;
    }
}



int main(int argc, char *argv[])
{
    char buff_name[10] = "aaa";
    char buff_passwd[10] = "111";
    name_passwd_did_in_user(buff_name,buff_passwd);
}